using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using System.Text;
 
var builder = WebApplication.CreateBuilder(args);

var Configuration = builder.Configuration;

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.OutputEncoding = Encoding.GetEncoding("GB2312");
Console.InputEncoding = Encoding.GetEncoding("GB2312");


var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
  
}

app.UseAuthorization();

app.MapControllers();

ImHelper.Initialization(new ImClientOptions
{
    Redis = new FreeRedis.RedisClient("127.0.0.1:6379,poolsize=10"),
    Servers = new[] { "127.0.0.1:6001" }
}); 

app.UseFreeImServer(new ImServerOptions
{
    Redis = new FreeRedis.RedisClient("127.0.0.1:6379,poolsize=10"),//Configuration["ImServerOption:RedisClient"]
    Servers =new[] { "127.0.0.1:6001" },// Configuration["ImServerOption:Servers"].Split(";"),
    Server = "127.0.0.1:6001",// Configuration["ImServerOption:Server"]
});

//app.MapGet("/", () => "Hello World!");

//var url = Configuration[WebHostDefaults.ServerUrlsKey];

//var warm = url.Split(';')[0] + "/Health";
//new HttpClient().GetAsync(warm).Wait();

app.Run();
